
if not SYSPATH then return end
-----------------------------------------
--服务器数据接收
--onTableInfo       更新桌子信息
--onPlayerState     更新玩家信息
-----------------------------------------
local model         = app.gamesUse("model")
local hall_model    = app.model("hall")

local function log(msg)
    print("--------------------RESPONSE--------------------",msg)
end

local meta  = {}
meta.update_start = false
meta.handler = nil
--更新玩家数据
function meta.onRoomData(param,actor)
	for k,v in pairs(param._list) do
		v.FaceUrl = crypto.decodeBase64(v.FaceUrl)
	end
	
	model.roomData = param
	print("进入房间后，得到的用户的数据---------")
	dump(model.roomData)
	MVC.facade:send(Event.EVENT_JCXJ_ROOM_TABLE,"")

	-- local function decodeBase64(str64)  
	-- 		local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'  
	-- 		local temp={}  
	-- 		for i=1,64 do  
	-- 			temp[string.sub(b64chars,i,i)] = i  
	-- 		end  
	-- 		temp['=']=0  
	-- 		local str=""  
	-- 		for i=1,#str64,4 do  
	-- 			if i>#str64 then  
	-- 				break  
	-- 			end  
	-- 			local data = 0  
	-- 			local str_count=0  
	-- 			for j=0,3 do  
	-- 				local str1=string.sub(str64,i+j,i+j)  
	-- 				if not temp[str1] then  
	-- 					return  
	-- 				end  
	-- 				if temp[str1] < 1 then  
	-- 					data = data * 64  
	-- 				else  
	-- 					data = data * 64 + temp[str1]-1
	-- 					str_count = str_count + 1  
	-- 				end  
	-- 			end  
	-- 			for j=16,0,-8 do  
	-- 				if str_count > 0 then  
	-- 					str=str..string.char(math.floor(data/math.pow(2,j)))  
	-- 					data=math.mod(data,math.pow(2,j))  
	-- 					str_count = str_count - 1  
	-- 				end  
	-- 			end  
	-- 		end  
		
	-- 		local last = tonumber(string.byte(str, string.len(str), string.len(str)))  
	-- 		if last == 0 then  
	-- 			str = string.sub(str, 1, string.len(str) - 1)  
	-- 		end  
	-- 		return str  
	-- 	end  

	-- 	for k,v in pairs(param._list) do
	-- 		v.FaceUrl = decodeBase64(v.FaceUrl)
	-- 	end
		
	-- 	model.roomData = param
	-- 	print("进入房间后，得到的用户的数据---------")
	-- 	dump(model.roomData)
	-- 	MVC.facade:send(Event.EVENT_JCXJ_ROOM_TABLE,"")
	end

--桌子信息推送
function meta.onTableInfo(param,actor)      
	print("JCXJ-onTableinfo-1")
	--model.gameData = param
	print("游戏开始发过来的数据")
	dump(param)

	MVC.facade:send(Event.EVENT_JCXJ_TABLE,param)
end

function meta.onResult( param,actor)
	print("sddfklklklsdklflksdlkfkllk;l看卢达克里斯")
	MVC.facade:send(Event.EVENT_JCXJ_RESERT,param)
end

function meta.onReconnect( param,actor)
	MVC.facade:send(Event.EVENT_JCXJ_RECONNECT,param)
end

function meta.onSignResult( param,actor)
	MVC.facade:send(Event.EVENT_JCXJ_SIGN_RESERT,param)
end
--文字聊天
function meta.onPlayerChat(param,actor)
	print("111111什么鬼是否返回表情消息-----------------")           
    MVC.facade:send(Event.EVENT_JCXJ_PLAYER_CHAT,param) 
end

--玩家离开
function meta.onRoomLeave(param,actor)      
	MVC.facade:send(Event.EVENT_JCXJ_LEAVE,param) 
end

--解散状态
function meta.onDismissApplyRec(param,actor)
	local succode = param.succode
	if succode == 1 then
		log("COMMON","申请解散房间成功")
	else
		local errcode = param.errcode
	end
end
--解散房间
function meta.onDismiss(param,actor)
	print("--解散房间")
	MVC.facade:send(Event.EVENT_JCXJ_DISMISS,param)
end

--解散房间动作
function meta.onDismissUpdate(param,actor)
	print("--解散房间动作")
	MVC.facade:send(Event.EVENT_JCXJ_DISMISS_UPDATE,param)
end

--解散房间结果
function meta.onDismissResult(param,actor)
	print("--解散房间结果")
	MVC.facade:send(Event.EVENT_JCXJ_DISMISS_RESULT,param)
end

--玩家状态包  离线在线
function meta.onPlayerState(param,actor)      
    MVC.facade:send(Event.EVENT_JCXJ_PLAYER_STATE,param)   
end

function meta.onLeaveRec(param,actor)
	MVC.facade:send(Event.EVENT_LEAVE_GAME,param)   
end

--是否准备
function meta.isReady(data)
    MVC.facade:send(Event.EVENT_JCXJ_READY,data)   
end

return meta

